/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package upc.jfactory.scp.bl.controller;

import java.util.ArrayList;
import java.util.List;
import upc.jfactory.scp.entidad.Competencia;
import upc.jfactory.scp.entidad.CompetenciaXPuestoOfertado;

/**
 *
 * @author Diego
 */
public class CompetenciasController {
public CompetenciasController(){}
 public List<Competencia> selectCompetencias() {
        List<Competencia> competencias = null;
        Competencia com;
        try { // Call Web Service Operation
            org.tempuri.ServicePyramid service = new org.tempuri.ServicePyramid();
            org.tempuri.ServicePyramidSoap port = service.getServicePyramidSoap();
            org.tempuri.ArrayOfCompetenciaBE result = port.getCompetencias();
            org.tempuri.CompetenciaBE comBE;
            for (int i = 0; i < result.getCompetenciaBE().size(); i++) {
                if (competencias == null) {
                    competencias = new ArrayList<Competencia>();
                }
                com = new Competencia();
                comBE = result.getCompetenciaBE().get(i);
                com.setIdCompetencia(comBE.getIdCompetencia());
                com.setNombreCompetencia(comBE.getNombreCompetencia());
                competencias.add(com);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return competencias;
    }

    public  int obtnercompetencia(int idcompetencia, int idAlumno) {
        int result = 0;
        try { // Call Web Service Operation
            org.tempuri.ServicePyramid service = new org.tempuri.ServicePyramid();
            org.tempuri.ServicePyramidSoap port = service.getServicePyramidSoap();
            result = port.getEvalCompByIDAlu(idcompetencia, idAlumno);

        } catch (Exception ex) {
            return result;
            // TODO handle custom exceptions here
        }
        return result;
    }

    public CompetenciaXPuestoOfertado obtnerCompetenciaById(int idcompetencia) {
        org.tempuri.CompetenciaBE result;
        CompetenciaXPuestoOfertado com = new CompetenciaXPuestoOfertado();
        try { // Call Web Service Operation
            org.tempuri.ServicePyramid service = new org.tempuri.ServicePyramid();
            org.tempuri.ServicePyramidSoap port = service.getServicePyramidSoap();
            result = port.getCompByID(idcompetencia);
            com.setIdCompetencia(result.getIdCompetencia());
            com.setNombreCompetencia(result.getNombreCompetencia());

        } catch (Exception ex) {
            // TODO handle custom exceptions here
        }
        return com;
    }
    public Competencia obtenerCompetenciaById(int idcompetencia) {
        org.tempuri.CompetenciaBE result;
        Competencia com = new Competencia();
        try { // Call Web Service Operation
            org.tempuri.ServicePyramid service = new org.tempuri.ServicePyramid();
            org.tempuri.ServicePyramidSoap port = service.getServicePyramidSoap();
            result = port.getCompByID(idcompetencia);
            com.setIdCompetencia(result.getIdCompetencia());
            com.setNombreCompetencia(result.getNombreCompetencia());

        } catch (Exception ex) {
            // TODO handle custom exceptions here
        }
        return com;
    }
}
